<template>
	<fixtitletopVue>
		<template #l>
			<view @click="back" class="iconfont icon-31fanhui1"></view>
		</template>
	</fixtitletopVue>
 <view class="con">
	 <view class="tit">
	 	  账号密码登录
	 </view>
	 <view class="inout">
		 <input v-model="senddata.phone" type="number" placeholder="请输入手机号" maxlength="11" placeholder-class="plca"/>
		 <input v-model="senddata.password" type="password" placeholder="请输入密码" placeholder-class="plca"/>
	 </view>
	 <view class="" style="overflow: hidden;"><button class="bu" :class="{bluebg:isok}" :disabled="!isok" @click="gologin">登录</button></view>
	 <view class="b">
		   <view class="l" @click="gophonecode">验证码登录</view>
		   <view class="r" @click="goforgite">忘记密码</view>
	 </view>
 </view>
</template>

<script setup>
import { computed,ref } from 'vue';
import fixtitletopVue from '../../components/fixtitletop/fixtitletop.vue';
import {getphonelogin} from '@/api/index.js'
   import userstore from '@/store/user.js'
	 const useuserstore=userstore()
const senddata=ref({
	phone:'',
	password:""
})
const isok=computed(()=>{
	return senddata.value.phone.trim().length==11&&senddata.value.password.trim().length>5
})
const goforgite=()=>{
	uni.navigateTo({
		url:"/pages/findMm/findMm"
	})
}
const back=()=>{
	uni.navigateBack()
}
const gologin=async()=>{
	const rudata=await getphonelogin(senddata.value)
	if(rudata.code==200){
		useuserstore.userinfo=rudata.data
		useuserstore.token=rudata.token
		uni.showToast({
			title:"登录成功！",
			icon:"none"
		})
		setTimeout(()=>{
			uni.reLaunch({
				url:"/pages/index/index"
			})
		},2000)
	}else if(rudata.code==0){
		uni.showToast({
			title:"用户不存在！",
			icon:"none"
		})
	}else{	
		uni.showToast({
			title:"账号或密码错误！",
			icon:"none"
		})
	}
}
const gophonecode=()=>{
	uni.redirectTo({
		url:"/pages/phonecodelogin/phonecodelogin"
	})
}
</script>

<style lang="scss" scoped>
	:deep(.plca){
		font-size: 25rpx !important;
		color: #7b7b7b !important;
	}
	.iconfont{
		font-size: 30rpx
	}
	.con{
		padding: 0 45rpx;
	}
	.tit{
		font-size: 45rpx;font-weight: 700;
		margin-top: 50rpx;
	}
	.inout{
		margin-top: 130rpx;
		width: 100%;
	}
	input{
		height: 90rpx;
		width: 100%;
		background-color: #f4f4f4;
		padding-left:20rpx;
		margin-bottom: 30rpx;
		font-size: 25rpx;
		border-radius: 10rpx;
	}
    .bu{
		margin-top: 85rpx;
		height: 90rpx;
		width: 100%;
		border-radius: 10rpx;
		font-size: 25rpx;color: #fff;
		font-weight: 700;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #dfdfdf;
	}
      .b{
		  display: flex;
		  justify-content: space-between;
		  margin-top: 30rpx;
		  font-size: 23rpx;
		  .l{
			  color: #6491f8;
		  }
		  .r{
			  color:#7b7b7b
		  }
	  }
</style>
